#include "Series.h"

namespace LightChart {
	Series::Series(const std::string & name, DataType type): name(name), type(type) {
		set_vector_type();
	}
	void Series::set_vector_type() {
		switch(type) {
		case UNKNOWN:
			break;
		case INTEGER:
			values = std::vector<int>();
			break;
		case DOUBLE_PRECISION:
			values = std::vector<double>();
			break;
		case S_TEXT:
			values = std::vector<std::string>();
			break;
		}
	}
	void Series::add(variant_values value) throw(boost::bad_get) {
		if (type == UNKNOWN) {
			type = boost::apply_visitor(StorageVisitor(), value);
			set_vector_type();
		}
		switch (type) {
		case INTEGER:
			get_int_vector().push_back(boost::get<int>(value));
			break;
		case DOUBLE_PRECISION:
			get_double_vector().push_back(boost::get<double>(value));
			break;
		case S_TEXT:
			get_string_vector().push_back(boost::get<std::string>(value));
			break;
		default:
			throw new boost::bad_get();
		}
	}
}
